#ifndef __Type_2_Type__
#define __Type_2_Type__

#include "GUIBase.h"
#include "Scheme/GUIImage.h"

namespace YGUI
{
    template<typename _Ty>
    struct type2type
    {
        static _Ty string2type(const String& value)
        {
            return _Ty();
        }

        static String type2string(_Ty value)
        {
            return "";
        }
    };

    template<>
    struct type2type<const Image*>
    {
        static const Image* string2type(const String& value)
        {
            return ValueConverter::string2Image(value);
        }

        static String type2string(const Image* value)
        {
            return ValueConverter::Image2string(value);
        }
    };

#define Type2TypeDefinition(_Ty, s2t, t2s) \
    template<>\
    struct type2type<_Ty>\
    {\
        static _Ty string2type(const String& value)\
        {\
            return s2t(value);\
        }\
\
        static String type2string(_Ty value)\
        {\
            return t2s(value);\
        }\
    };

    Type2TypeDefinition(bool, ValueConverter::string2boolean, ValueConverter::boolean2string);
    Type2TypeDefinition(float, ValueConverter::string2float, ValueConverter::float2string);
#undef Type2TypeDefinition

#define Type2TypeDefinition(_Ty, s2t, t2s) \
    template<>\
    struct type2type<_Ty>\
    {\
        static _Ty string2type(const String& value)\
        {\
            return s2t(value);\
        }\
\
        static String type2string(const _Ty& value)\
        {\
            return t2s(value);\
        }\
    };

    Type2TypeDefinition(Colour, ValueConverter::string2Colour, ValueConverter::Colour2string);
    Type2TypeDefinition(ColourRect, ValueConverter::string2ColourRect, ValueConverter::ColourRect2string);
    Type2TypeDefinition(UDim<float>, ValueConverter::string2UDim<float>, ValueConverter::UDim2string<float>);
    Type2TypeDefinition(UVector2<float>, ValueConverter::string2UVector2<float>, ValueConverter::UVector22string<float>);
    Type2TypeDefinition(URect<float>, ValueConverter::string2URect<float>, ValueConverter::URect2string<float>);
    Type2TypeDefinition(HorzontalFormatting, ValueConverter::string2HorzFmt, ValueConverter::HorzFmt2string);
    Type2TypeDefinition(VerticalFormatting, ValueConverter::string2VertFmt, ValueConverter::VertFmt2string);
    Type2TypeDefinition(HorzontalTextFormatting, ValueConverter::string2HorzTextFmt, ValueConverter::HorzTextFmt2string);
    Type2TypeDefinition(VerticalTextFormatting, ValueConverter::string2VertTextFmt, ValueConverter::VertTextFmt2string);
    Type2TypeDefinition(DimensionType, ValueConverter::string2DimType, ValueConverter::DimType2string);
    Type2TypeDefinition(DimensionOperator, ValueConverter::string2DimOperator, ValueConverter::DimOperator2string);
    Type2TypeDefinition(FrameComponentType, ValueConverter::string2FrmType, ValueConverter::FrmType2string);
    Type2TypeDefinition(String, String, String);

#undef Type2TypeDefinition

#define Type2TypeDefinition(_Ty, s2t, t2s) \
    template<>\
    struct type2type<_Ty>\
    {\
        static const _Ty* string2type(const String& value)\
        {\
            return s2t(value);\
        }\
\
        static String type2string(const _Ty* value)\
        {\
            return t2s(value);\
        }\
    };

    Type2TypeDefinition(Image, ValueConverter::string2Image, ValueConverter::Image2string);

#undef Type2TypeDefinition
}
#endif